Page({
  data: {
    // 用户信息
    personList: []
  },
  onLoad() {
   
  },
  onShow() {
    let that = this;
    that.data.personList = my.getStorageSync({ key: 'personInfoList' }).data;
    console.log('重新加载页%%%%%%%%%%%%%%%%')
  },
  addPerson() {
    console.log('新增入住')
    my.ix.readCard({
      success: (r) => {
        console.log("新增入住success", r.info.iDCard, r.info.peopleName);
        console.log(r)
        if(r.success){
          my.ix.faceVerify({
            verifyType: 'idCard',
            option: 'life',
            certNo: r.info.iDCard,
            certName: r.info.peopleName,
            success: (res) => {
              console.log('faceVerify forPay success', res);
              console.log(r.info.iDCard, r.info.peopleName);
              let per = my.getStorageSync({ key: 'personInfoList' }).data;
              per.push(r)
              console.log('res', per)
              my.setStorage({
                key: 'personInfoList',
                data: per,
                success: function() {
                  // my.alert({content: '写入成功'});
                }
              });
              console.log( my.getStorageSync({ key: 'personInfoList' }).data)
              my.redirectTo({
                url: './status-return'
              });
            },
            fail: (res) => {
              console.log('faceVerify forPay fail', res);
            }
          });
        }
      },
      fail: (r) => {
        console.log("fail, errorCode:" + r.error);
        my.showToast({
          type: 'fail',
          content: '请拿起身份证重新刷一次',
          duration: 3000,
          success: () => {
            // my.alert({
            //   title: 'toast 消失了',
            // });
          },
        });
      }
    });
  },
  // 确定入住
  sure() {
    my.navigateTo({
      url: '../witness-contrast'
    });
  },
  // 不住了
  cancle() {
    console.log('不住了')
    my.reLaunch({url:'/pages/index/index'});

    // my.redirectTo({
    //   url: '/pages/index/index'
    // });
  }
});
